package iqq.util;

import iqq.util.cache.Cache;

import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.ImageIcon;

/**
 * @author ChenZhiHui
 * @create-time 2013-3-6
 */
public class ImageManager {
	public static ImageIcon getImageIcon(String imageName) {
		return getImageIcon(imageName, null);
	}

	public static ImageIcon getImageIcon(String imageName, String description) {
		ImageIcon imageIcon = (ImageIcon) Cache.get(imageName);
		if (imageIcon == null) {
			imageIcon = description == null ? new ImageIcon(
					ResouceLoader.getResouce(imageName)) : new ImageIcon(
					ResouceLoader.getResouce(imageName), description);
			Cache.add(imageName, imageIcon);
		}
		return imageIcon;
	}

	public static Image getImage(String imageName) {
		return getImageIcon(imageName).getImage();
	}

}
